<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
  <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
 <c:set var="path" value="${pageContext.request.contextPath}"/> 
   
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<base href="${path}/pages/">
<meta charset="UTF-8">
<title>登录</title>
<link rel="stylesheet" href="../layui/css/layui.css">
<link href="../css/style.css" rel="stylesheet" type="text/css" />
</head>
<body >
<div class="login layui-anim layui-anim-upbit">
<div class='login_title'>

<h5><pre>         每部电影的的女主才是电影的灵魂</pre></h5>

</div>
<div class="layui-form">
<div class="layui-form-item">
    <label  class="layui-form-label">手机号</label>
   <div class="layui-input-inline">
      <input style="width: 190px" type="text" name="phoneNumber" value="${user.phoneNumber}" required lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input">
   </div>
   <div class="layui-form-mid layui-word-aux" id="phoneNumberHint"></div>
</div>
<div class="layui-form-item">
    <label class="layui-form-label">密码</label>
   <div class="layui-input-inline">
      <input type="password" name="password" value="${user.password}"  placeholder="请输入"required lay-verify="required" autocomplete="off" class="layui-input">
   </div>
   <div class="layui-form-mid layui-word-aux" id="passwordHint"></div>
</div>
    
  <div class="layui-form-item">
    <div class="layui-input-block">
      <button class="layui-btn" lay-submit lay-filter="formDemo">立即登录</button>
      <button onclick="javascript:window.location.href='register.jsp'" class="layui-btn" style="margin-left:27px">注册 </button>
    </div>
  </div>
</div>

</div>
<script src="../layui/layui.js"></script>
<script>
//Demo
/*  name=
   用户名:UName
   密码:Pd
   重新输入的密码:RePd
   手机号:PhoneNb
   邮箱号:Email
 */
layui.use('form', function(){
  var form = layui.form;
  var $ = layui.$;

  //监听提交
	form.on('submit(formDemo)', function(data) {
		$.post('${path}/action/user/login', data.field, function(json) {
				if(json.code==1){
					window.location.href = '${path}/action/user/index';
				}else if(json.code==2){
					$('#phoneNumberHint').html('该用户不存在');
				}else if(json.code==3){
					$('#passwordHint').html('密码错误');
				}

			}, 'JSON');
	});
});
</script>

</body>
</html>